<%-- 
  -- Body List para Course.
  --
  -- @author ariel.piechotka
--%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/displaytag-el.tld" prefix="display" %>
<%@ taglib uri="/WEB-INF/security.tld" prefix="security" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%-- Librerias para EXT library --%>
<link rel="stylesheet" type="text/css" href="<html:rewrite page='/protected/script/ext-1.1.1/resources/css/ext-all.css'/>" />
<link rel="stylesheet" type="text/css" href="<html:rewrite page='/protected/script/ext-1.1.1/resources/css/xtheme-default.css'/>" />

<script src="<html:rewrite page='/protected/script/ext-1.1.1/adapter/ext/ext-base.js'/>" type="text/javascript"></script>
<script src="<html:rewrite page='/protected/script/ext-1.1.1/ext-all.js'/>" type="text/javascript"></script>

<script type="text/javascript">
    function modifyCourse(courseId) {
        var hiddenCourseId = $("modifyIdId");
        hiddenCourseId.value = courseId;        
        var form = $("modifyCourseFormId");
        form.submit();
    } 

    function modifyInstalments(courseId) {
        var hiddenCourseId = $("modifyInstIdId");
        hiddenCourseId.value = courseId;        
        var form = $("modifyInstalmentsFormId");
        form.submit();
    } 

    function viewEnrollments(courseId) {
        var hiddenCourseId = $("viewEnrollIdId");
        hiddenCourseId.value = courseId;        
        var form = $("viewEnrollmentsFormId");
        form.submit();
    } 
</script>


<%-- El ID del form NO debe ser modificado. Se usa desde el menu --%>
<html:form action="/protected/listCourses.do" styleId="courseFormId">
    <%-- Inyectados por Javascript --%>
    <html:hidden name="courseForm" property="id" styleId="courseToDeleteId" value=""/>
    <%-- No pertenece al form de Struts. Se carga cada vez q se selecciona un curso a eliminar --%>
<%-- !    <input type="hidden" id="courseToDeleteId" value="" > --%>
    
    <h2>Cursos</h2>

    <bean:define id="courses" name="courseForm" property="courses" />
    <display:table name="pageScope.courses" sort="list" export="true" pagesize="15" style="font-size: 10pt;" requestURI="/protected/listCourses.do" id="row" class="displayTable">

        <display:column title="Modificar" class="columnGifLink" media="html">
            <img src="<html:rewrite page='/protected/img/kedit.png'/>" alt="" name="submitB" onclick="modifyCourse('<bean:write name="row" property="id" />')" title="Modifica los datos del curso...">
        </display:column>

        <display:column title="Cuotas" class="columnGifLink" media="html">
            <img src="<html:rewrite page='/protected/img/kedit.png'/>" alt="" name="submitBInst" onclick="modifyInstalments('<bean:write name="row" property="id" />')" title="Modifica las cuotas del curso...">
        </display:column>

        <display:column title="Ver inscriptos" class="columnGifLink" media="html">
            <img src="<html:rewrite page='/protected/img/user.png'/>" alt="" name="submitBEnrolled" onclick="viewEnrollments('<bean:write name="row" property="id" />')" title="Accede a los participantes inscriptos en el curso...">
        </display:column>

        <display:column title="Nombre" property="name" sortable="true" />
        <display:column title="Ente" property="body.name" sortable="true" />
		<display:column media="csv excel pdf" title="Tipo de curso" property="courseType.description" sortable="false" />
		<display:column media="csv excel pdf" title="Primera fecha de vto." property="firstDueDate" sortable="false" />
    </display:table>    

</html:form>

<%-- Inyectados por Javascript --%>
<div id="modifyDivId" class="hideClass">
    <html:form action="/protected/showCourse" styleId="modifyCourseFormId">
        <html:hidden property="id" value="" styleId="modifyIdId" />
    </html:form>
</div>
<div id="modifyDivId" class="hideClass">
    <html:form action="/protected/showInstalments" styleId="modifyInstalmentsFormId">
        <html:hidden property="id" value="" styleId="modifyInstIdId" />
    </html:form>
</div>
<div id="modifyDivId" class="hideClass">
    <html:form action="/protected/listEnrollments" styleId="viewEnrollmentsFormId">
        <html:hidden property="id" value="" styleId="viewEnrollIdId" />
    </html:form>
</div>
